package servlets;

import beans.ManagerInfoBean;
import services.ManagerService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class registerServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("id");
        String pwd = request.getParameter("password");
        String userType = request.getParameter("userType");
        PrintWriter out = response.getWriter();

        ManagerInfoBean majBean = new ManagerInfoBean();
        majBean.setId(id);
        majBean.setPassword(pwd);
        majBean.setIsRoot(userType);

        ManagerService maj = new ManagerService();
        if(maj.insertManager(majBean) != 0)
            out.print("true");
        else
            out.print("false");
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
